#include "main.h"
#include "CaiDan.h"
#include "OLED.h"
#include "pidControl.h"
#include "SailBorad_entry.h"

uint8_t func_index=0;
uint8_t clear_flag=0;

void show0(void)
{
	OLED_ShowString(1,1,(uint8_t *)"Show Angle     <");
	OLED_ShowString(2,1,(uint8_t *)"Set Angle");
	OLED_ShowString(3,1,(uint8_t *)"Set Position");
	OLED_ShowString(4,1,(uint8_t *)"Set Fan");
}

void show1(void)
{
	OLED_ShowString(1,1,(uint8_t *)"Show Angle");
	OLED_ShowString(2,1,(uint8_t *)"Set Angle      <");
	OLED_ShowString(3,1,(uint8_t *)"Set Position");
	OLED_ShowString(4,1,(uint8_t *)"Set Fan");
}

void show2(void) {
	OLED_ShowString(1,1,(uint8_t *)"Show Angle");
	OLED_ShowString(2,1,(uint8_t *)"Set Angle");
	OLED_ShowString(3,1,(uint8_t *)"Set Position   <");
	OLED_ShowString(4,1,(uint8_t *)"Set Fan");
}

void show3(void) {
	OLED_ShowString(1,1,(uint8_t *)"Show Angle");
	OLED_ShowString(2,1,(uint8_t *)"Set Angle");
	OLED_ShowString(3,1,(uint8_t *)"Set Position");
	OLED_ShowString(4,1,(uint8_t *)"Set Fan        <");
}
/*二级：Show Angle*/
/*第二题题目*/
void show4(void)
{
	OLED_ShowString(1,1,(uint8_t *)"Angle:");
	OLED_ShowSignedNum(1,7,Sail_angle,3);
	OLED_ShowString(2,1,(uint8_t *)"Back           <");
}
/*二级：Set Angle*/
void show5(void)
{
	OLED_ShowString(1,1,(uint8_t *)"Angle:");
	OLED_ShowSignedNum(1,6,abs(Sail_angle_Target),3);
	OLED_ShowString(2,1,(uint8_t *)"Position:");
	OLED_ShowNum(2,10,DuoJi_Angle/84.0*5+15,2);
	OLED_ShowString(2,13,(uint8_t *)"cm");
	OLED_ShowString(3,1,(uint8_t *)"Enter          <");
}
/*二级：set position*/
/*第五题题目*/
void show6(void)
{
	OLED_ShowString(1,1,(uint8_t *)"Position:");
	OLED_ShowNum(1,10,DuoJi_Angle/84.0*5+15,2);
	OLED_ShowString(1,13,(uint8_t *)"cm");
	OLED_ShowString(2,1,(uint8_t *)"Angle:");
	OLED_ShowSignedNum(2,7,Sail_angle,3);
	OLED_ShowString(3,1,(uint8_t *)"Enter          <");
}
/*二级：正在控制风扇转速*/
/*第一题题目*/
void show7(void)
{
	OLED_ShowString(1,1,(uint8_t *)"Fan:");
	OLED_ShowSignedNum(1,5,abs(button),3);
	OLED_ShowString(1,9,(uint8_t *)"%");
	OLED_ShowString(2,1,(uint8_t *)"Angle:");
	OLED_ShowSignedNum(2,7,Sail_angle,3);
	OLED_ShowString(3,1,(uint8_t *)"Back           <");
}
/*三级：正在通过风扇控制帆板角度*/
/*第四题题目*/
void show8(void)
{
	OLED_ShowString(1,1,(uint8_t *)"Angle:");
	OLED_ShowSignedNum(1,7,Sail_angle,3);
	OLED_ShowString(2,1,(uint8_t *)"FanPWM:");
	OLED_ShowSignedNum(2,7,Final_Calc,4);
	OLED_ShowString(3,1,(uint8_t *)"Back           <");
}

Menu_table  table[9]=
{
    {0,1,4,(*show0)},
    {1,2, 5,(*show1)},
    {2,3, 6,(*show2)},
    {3,0,7,(*show3)},

    {4,4, 0,(*show4)},
    {5, 5, 8, (*show5)},
    {6, 6, 0, (*show6)},
	{7, 7, 0, (*show7)},

	{8, 8, 0, (*show8)},

};
